#!/usr/bin/python
# coding=utf-8
# 导入pymysql库
from pymysql import connect

try:
    conn = connect(
        host='127.0.0.1',
        port=3306,
        user='root',
        password='root',
        db='mysql',
        charset='utf8')
    cursor = conn.cursor()

except Exception as e:
    print(e)
else:
    sql = "select * from user".encode('utf-8')
    cursor.execute(sql)
    result = cursor.fetchall()
    for item in result:
        print(item)
    print('Connect Success:%s' % cursor)
